﻿import urllib2

# response = urllib2.urlopen("http://www.baidu.com")
# print response.read()

# request = urllib2.Request('http://www.xxxx.com')
# try:
    # urllib2.urlopen(request,10)
# except urllib2.URLError, e:
    # e.reason
req = urllib2.Request('http://blog.csdn.net/cqcre')
try:
    urllib2.urlopen(req)
except urllib2.HTTPError, e:
    print e.code
    